/**
 * 
 */
package fr.utbm.gi.vi51.slizers.framework.learning;

import java.util.List;

/**
 * Abstract implementation of a Q-Learning problem.
 * 
 * @author Tarik Belabbas
 * 
 */
public abstract class QAbstractProblem< StateType extends QState, ActionType extends QAction >
		implements QProblem< StateType, ActionType >
{
	/**
	 * The learning rate, alpha.
	 */
	private final float				alphaLearningRate;

	/**
	 * The discount rate, gamma.
	 */
	private final float				gammaDiscountRate;

	/**
	 * The rho value.
	 */
	private final float				rho;

	/**
	 * The nu value.
	 */
	private final float				nu;

	/**
	 * The current state of the problem.
	 */
	private StateType					currentState;

	/**
	 * The tree map storing states and the possible actions from these states.
	 */
	//private final Map< StateType, List< ActionType > > actions =
	//	new TreeMap< StateType, List< ActionType > >( new QComparator() );

	/**
	 * Parameterized constructor.
	 * 
	 * @param _alphaLearningRate the learning rate
	 * @param _gammaDiscountRate the discount rate
	 * @param _rho the rho value
	 * @param _nu the nu value
	 */
	public QAbstractProblem( float _alphaLearningRate, float _gammaDiscountRate,
			float _rho, float _nu )
	{
		this.alphaLearningRate	= _alphaLearningRate;
		this.gammaDiscountRate	= _gammaDiscountRate;
		this.rho				= _rho;
		this.nu					= _nu;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * fr.utbm.gi.vi51.slizers.framework.learning.QProblem#getAlphaLearningRate
	 * ()
	 */
	@Override
	public float getAlphaLearningRate()
	{
		return this.alphaLearningRate;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * fr.utbm.gi.vi51.slizers.framework.learning.QProblem#getGammaDiscountRate
	 * ()
	 */
	@Override
	public float getGammaDiscountRate()
	{
		return this.gammaDiscountRate;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see fr.utbm.gi.vi51.slizers.framework.learning.QProblem#getRho()
	 */
	@Override
	public float getRho()
	{
		return this.rho;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see fr.utbm.gi.vi51.slizers.framework.learning.QProblem#getNu()
	 */
	@Override
	public float getNu()
	{
		return this.nu;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * fr.utbm.gi.vi51.slizers.framework.learning.QProblem#getCurrentState()
	 */
	@Override
	public StateType getCurrentState()
	{
		return this.currentState;
	}
	

	@Override
	abstract public List<ActionType> getAvailableActionsFor(StateType _state);
}
